home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / VIEWEX.PAK / INPUTVW.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  108 lines

  1. // inputvw.cpp : implementation file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "viewex.h"
  15.  
  16. #ifdef _DEBUG
  17. #undef THIS_FILE
  18. static char BASED_CODE THIS_FILE[] = __FILE__;
  19. #endif
  20.  
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CInputView
  23.  
  24. IMPLEMENT_DYNCREATE(CInputView, CFormView)
  25.  
  26. CInputView::CInputView()
  27.     : CFormView(CInputView::IDD)
  28. {
  29.     //{{AFX_DATA_INIT(CInputView)
  30.     m_strData = "";
  31.     m_iColor = -1;
  32.     //}}AFX_DATA_INIT
  33. }
  34.  
  35. CInputView::~CInputView()
  36. {
  37. }
  38.  
  39. void CInputView::OnUpdate(CView*, LPARAM, CObject*)
  40. {
  41.     CMainDoc* pDoc = GetDocument();
  42.     m_strData = pDoc->m_strData;
  43.  
  44.     if (pDoc->m_colorData == RGB(255, 0, 0))
  45.         m_iColor = 0;
  46.     else if (pDoc->m_colorData == RGB(0, 255, 0))
  47.         m_iColor = 1;
  48.     else if (pDoc->m_colorData == RGB(0, 0, 255))
  49.         m_iColor = 2;
  50.     else
  51.         m_iColor = -1;
  52.  
  53. TRACE2("OnUpdate: m_iColor = %d ($%lx)\n", m_iColor, pDoc->m_colorData);
  54.  
  55.     UpdateData(FALSE);  // set the data into the controls
  56. }
  57.  
  58. void CInputView::DoDataExchange(CDataExchange* pDX)
  59. {
  60.     CFormView::DoDataExchange(pDX);
  61.     //{{AFX_DATA_MAP(CInputView)
  62.     DDX_Text(pDX, IDC_EDIT1, m_strData);
  63.     DDX_Radio(pDX, IDC_RADIO1, m_iColor);
  64.     //}}AFX_DATA_MAP
  65. }
  66.  
  67. BEGIN_MESSAGE_MAP(CInputView, CFormView)
  68.     //{{AFX_MSG_MAP(CInputView)
  69.     ON_EN_CHANGE(IDC_EDIT1, OnDataChange)
  70.     ON_BN_CLICKED(IDC_RADIO1, OnDataChange)
  71.     ON_BN_CLICKED(IDC_RADIO2, OnDataChange)
  72.     ON_BN_CLICKED(IDC_RADIO3, OnDataChange)
  73.     //}}AFX_MSG_MAP
  74. END_MESSAGE_MAP()
  75.  
  76. /////////////////////////////////////////////////////////////////////////////
  77. // CInputView message handlers
  78.  
  79. void CInputView::OnDataChange()
  80. {
  81.     if (!UpdateData())
  82.         return;
  83.  
  84.     CMainDoc* pDoc = GetDocument();
  85.     COLORREF color = RGB(255 * (m_iColor == 0),
  86.                         255 * (m_iColor == 1),
  87.                         255 * (m_iColor == 2));
  88.  
  89.     BOOL bUpdate = FALSE;
  90.     if (m_strData != pDoc->m_strData)
  91.     {
  92.         pDoc->m_strData = m_strData;
  93.         bUpdate = TRUE;
  94.     }
  95.     if (color != pDoc->m_colorData)
  96.     {
  97.         pDoc->m_colorData = color;
  98.         bUpdate = TRUE;
  99.     }
  100.     if (bUpdate)
  101.     {
  102.         // if the document stored data then we would call SetModifiedFlag here
  103.         pDoc->UpdateAllViews(this);
  104.     }
  105. }
  106.  
  107. /////////////////////////////////////////////////////////////////////////////
  108.